package com.ruix.app.model;

import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created by hadexs on 2017/5/9.
 */

public class WXAccessToken implements Serializable{
    private String accessToken;
    private String refreshToken;
    private String openid;
    private String scope;
    private String unionid;
    private long expiresIn;


    public WXAccessToken parse(JSONObject object){
        if (object != null){
            setAccessToken(object.optString("access_token",""));
            setRefreshToken(object.optString("refresh_token",""));
            setOpenid(object.optString("openid",""));
            setScope(object.optString("scope",""));
            setUnionid(object.optString("unionid",""));
            setExpiresIn(object.optInt("expires_in",0));
        }
        return this;
    }



    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public String getRefreshToken() {
        return refreshToken;
    }

    public void setRefreshToken(String refreshToken) {
        this.refreshToken = refreshToken;
    }

    public String getOpenid() {
        return openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    public String getUnionid() {
        return unionid;
    }

    public void setUnionid(String unionid) {
        this.unionid = unionid;
    }

    public long getExpiresIn() {
        return expiresIn;
    }

    public void setExpiresIn(long expiresIn) {
        this.expiresIn = expiresIn;
    }

    @Override
    public String toString() {
        return "WXAccessToken{" +
                "accessToken='" + accessToken + '\'' +
                ", refreshToken='" + refreshToken + '\'' +
                ", openid='" + openid + '\'' +
                ", scope='" + scope + '\'' +
                ", unionid='" + unionid + '\'' +
                ", expiresIn=" + expiresIn +
                '}';
    }
}
